package com.ticket.controller.api;

import com.ticket.entity.Feedback;
import com.ticket.entity.ForumPost;
import com.ticket.entity.Match;
import com.ticket.service.IFeedbackService;
import com.ticket.service.IForumService;
import com.ticket.service.IMatchService;
import com.ticket.utils.Result;
import com.ticket.utils.UserContext;
import com.ticket.vo.MatchDetailVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api")
public class HomeController {

    @Autowired
    private IMatchService matchService;

    @Autowired
    private IForumService forumService;

    @Autowired
    private IFeedbackService feedbackService;

    @GetMapping("/matches/recent")
    public Result<List<MatchDetailVO>> getRecentMatches() {
        return Result.success(matchService.getRecentMatches(5));
    }

    @GetMapping("/forum/posts/recent")
    public Result<List<ForumPost>> getRecentPosts() {
        return Result.success(forumService.getRecentPosts(5));
    }

    @GetMapping("/feedbacks/recent")
    public Result<List<Feedback>> getRecentFeedbacks() {
        Long userId = UserContext.getCurrentUserId();
        return Result.success(feedbackService.getRecentFeedbacks(userId, 5));
    }
}
